﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ResourcesUserControl.ascx.cs" Inherits="UCWebpart.Admin.ResourcesUserControl" %>


<table><tr>
    <td>
<div style="overflow-y:scroll;height:250px;width:250px; text-align: left;">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="resId" DataSourceID="SqlDataSource1" CellPadding="4" ForeColor="#333333" GridLines="None" OnRowDeleted="GridView1_RowDeleted">
    <AlternatingRowStyle BackColor="White" />
    <Columns>
        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
        <asp:BoundField DataField="resId" HeaderText="resId" InsertVisible="False" ReadOnly="True" SortExpression="resId" Visible="False" />
        <asp:TemplateField HeaderText="名称" SortExpression="resName">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("resName") %>'></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label1" runat="server" Text='<%# Bind("resName") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="resIcon" HeaderText="图标" SortExpression="resIcon" Visible="False" />
        <asp:BoundField DataField="resLastUser" HeaderText="上次使用者" SortExpression="resLastUser" ReadOnly="True" Visible="False" />
        <asp:BoundField DataField="resLastTime" HeaderText="上次使用时间" SortExpression="resLastTime" Visible="False" ReadOnly="True" />
        <asp:CheckBoxField DataField="del" HeaderText="删除" SortExpression="del" Visible="False" />
    </Columns>
    <EditRowStyle BackColor="#2461BF" />
    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
    <RowStyle BackColor="#EFF3FB" />
    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
    <SortedAscendingCellStyle BackColor="#F5F7FB" />
    <SortedAscendingHeaderStyle BackColor="#6D95E1" />
    <SortedDescendingCellStyle BackColor="#E9EBEF" />
    <SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
</div>
    </td><td style="width:100px">
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource3" DataTextField="mtrName" DataValueField="mtrId" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
            </asp:DropDownList>
        <br />
        <br/>
         <asp:Button ID="Button1" runat="server" OnClick="Button1_Click1" Text="保存" />
         </td>
    <td style="width:300px">
        <div style="overflow-y:scroll;height:250px;width:350px; text-align: left;">
            <asp:CheckBoxList ID="Recourses" runat="server">
            </asp:CheckBoxList>
    </div> 
    </td>
</tr></table>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:meetingroomManagementConnectionString %>" DeleteCommand="update [MTR_bas_Resources] set del = '0' WHERE [resId] = @resId" InsertCommand="INSERT INTO [MTR_bas_Resources] ([resId], [resName], [resIcon], [resLastUser], [resLastTime], [del]) VALUES (@resId, @resName, @resIcon, @resLastUser, @resLastTime, @del)" SelectCommand="SELECT * FROM [MTR_bas_Resources] where del =1 order by resId desc" UpdateCommand="UPDATE [MTR_bas_Resources] SET [resName] = @resName, [resIcon] = @resIcon, [resLastUser] = @resLastUser, [resLastTime] = @resLastTime, [del] = '1' WHERE [resId] = @resId">
    <DeleteParameters>
        <asp:Parameter Name="resId" Type="Int32" />
    </DeleteParameters>
    <InsertParameters>
        <asp:Parameter Name="resId" Type="Int32" />
        <asp:Parameter Name="resName" Type="String" />
        <asp:Parameter Name="resIcon" Type="String" />
        <asp:Parameter Name="resLastUser" Type="String" />
        <asp:Parameter Name="resLastTime" Type="DateTime" />
        <asp:Parameter Name="del" Type="Boolean" />
    </InsertParameters>
    <UpdateParameters>
        <asp:Parameter Name="resName" Type="String" />
        <asp:Parameter Name="resIcon" Type="String" />
        <asp:Parameter Name="resLastUser" Type="String" />
        <asp:Parameter Name="resLastTime" Type="DateTime" />
        <asp:Parameter Name="resId" Type="Int32" />
    </UpdateParameters>
</asp:SqlDataSource>
    
<div id="mtrRes" runat="server">
<p>
            <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                ConnectionString="<%$ ConnectionStrings:meetingroomManagementConnectionString %>" 
                SelectCommand="SELECT [resName], [resId] FROM [MTR_bas_Resources] where del = 1">
            </asp:SqlDataSource>
            
            
            <asp:SqlDataSource ID="SqlDataSource3" runat="server"
                 ConnectionString="<%$ ConnectionStrings:meetingroomManagementConnectionString %>" 
                SelectCommand="
                SELECT MTR_bas_Meetingroom.* FROM MTR_bas_Meetingroom (nolock) where mtrDelete=1 and 
                3 in (select distinct adminLevel from MTR_bas_Admin(nolock) where adminName=@adminName and Available=1)
                union
                select MTR_bas_Meetingroom.* from MTR_bas_Admin with(nolock) join MTR_bas_Meetingroom with(nolock) 
                on MTR_bas_Admin.[VenueType]=MTR_bas_Meetingroom.[type]
                where adminName=@adminName and MTR_bas_Admin.Available='1' and MTR_bas_Meetingroom.mtrDelete='1'">
                <SelectParameters>
                    <asp:SessionParameter Name="adminName" SessionField="userName" />
                </SelectParameters>
            </asp:SqlDataSource>
        </p>
</div>
<div id="res" runat="server">
    请输入资源名称： <asp:TextBox ID="resName" runat="server" Width="106px"></asp:TextBox>
    <p>
        <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="添加" />
    </p>
        <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</div>
